<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="../../common/Include_input_head.jsp" %>

<title>维护用户</title>

<script type="text/javascript" src="${basePath }/component/jsuggest/lib/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="${basePath }/component/jsuggest/lib/jquery.ajaxQueue.js"></script>
<script type="text/javascript" src="${basePath }/component/jsuggest/lib/thickbox-compressed.js"></script>
<script type="text/javascript" src="${basePath }/component/jsuggest/jquery.autocomplete.pack.js"></script>
<link rel="stylesheet" type="text/css" href="${basePath }/component/jsuggest/jquery.autocomplete.css"/>
<link rel="stylesheet" type="text/css" href="${basePath }/component/jsuggest/lib/thickbox.css"/>
<!--------------------flexbox开始--------------------->
<link rel="stylesheet" type="text/css" href="${basePath }/component/FlexBox/css/jquery.flexbox.css"/>
<script type="text/javascript" src="${basePath }/component/FlexBox/js/jquery.flexbox.js"></script>
<script type="text/javascript" src="${basePath }/id/idUser-departsJS.action"></script>
<!--------------------flexbox结束--------------------->

<script type="text/javascript">
    detailPageStyle();
    var left_index = 0;
    var right_index = 0;
    var size = parseInt('<s:property value="%{#AccessApp.size()}"/>');
    ;
    $(document).ready(function () {
        $("#userPwd").val($("#userPwd_hide").val());//这里重新设置一下，因为UUR界面会把password清空。
        //flexbox配置
        var myflexbox = $('.abcdefg').flexbox(countries, {
            paging: {
                summaryTemplate: '第{start}-{end}条  总计{total}条'
            },
            initialValue: '<s:property value="tsysUser.depart.departid"/>',
            onSelect: function () {
                $('#departname').val(this.value);
            }
        });
        var aaa = document.getElementById("tsysUser.depart.departid_input");
        aaa.value = '<s:property value="tsysUser.depart.departname"/>';

        /**********tab页开始***************/
            //第一个二级菜单选中
        $("li[id='ulli_0']").addClass("current");
        if ($.browser.mozilla || ($.browser.msie && $.browser.version > 8)) {
            setTimeout("showButtonList()", 500);
        } else {
            showButtonList();
        }

        //只读模式
        var url = location.href;
        var readOnly = false;
        if (url.indexOf("readOnlyPage") != -1) {
            var readOnlyPage_value_index = url.indexOf("readOnlyPage") + "readOnlyPage=".length;
            readOnly = url.substr(readOnlyPage_value_index, 4) == 'true';
        }
        if (readOnly) {
            $("li a[href*='idRoleButton-list.action']").each(function (i) {
                var href = $(this).attr("href");
                $(this).attr("href", href + "&readOnlyPage=true");
            });
            $("div iframe[src*='idRoleButton-list.action']").each(function (i) {
                var href = $(this).attr("src");
                $(this).attr("src", href + "&readOnlyPage=true");
            });
        }
        /**********tab页结束******************/
        $(".simpleTab_top li:first a span").click();
    });
    function doSave() {

        var userLoginId = $("#userLoginId").val();
        var userPwd = $("#userPwd").val();

        var departid = document.getElementById("tsysUser.depart.departid_hidden").value;        //部门ID
        if (userLoginId == "") {
            alert("用户登录账号不允许为空！");
            document.getElementById("userLoginId").focus();
            return false;
        }
        if (isContainSpecialChar(userLoginId)) {
            alert("用户登录账号不允许包含特殊字符！");
            document.getElementById("userLoginId").focus();
            return false;
        }
        if (isContainChinese(userLoginId)) {
            alert("用户登录账号不接受中文！");
            document.getElementById("userLoginId").focus();
            return false;
        }
        if (getLength(userLoginId) > 50) {
            alert("用户登录账号长度不能超过50！");
            document.getElementById("userLoginId").focus();
            return false;
        }
        if (userPwd == "") {
            alert("用户登录密码不允许为空！");
            document.getElementById("userPwd").focus();
            return false;
        }

        if (departid == "") {
            alert("用户所属部门不允许为空！");
            //document.getElementById("userPwd").focus();
            return false;
        }

        if (isContainSpecialChar(userPwd)) {
            alert("用户登录密码不允许包含特殊字符！");
            document.getElementById("userPwd").focus();
            return false;
        }
        if (isContainChinese(userPwd)) {
            alert("验证码不接受中文！");
            document.getElementById("userPwd").focus();
            return false;
        }
        if (getLength(userPwd) > 50) {
            alert("用户登录密码长度不能超过50！");
            document.getElementById("userPwd").focus();
            return false;
        }
        return super_doSave();

    }
    /***********控制tab页**************************/
    /**
     * 调整权限菜单按钮格式
     * @memberOf {TypeName}
     */
    function showButtonList() {
        var buttons_width = '';
        $("li[id^='ulli_']").each(function (i) {
            if (i != 0) buttons_width += ';';
            buttons_width += i + ":" + $("#ulli_" + i).width() + ":" + $(this).find("span").html();
        });
        var width_document = document.body.clientWidth;
        var ws = buttons_width.split(";");
        var wis = 0;
//        alert(width_document);
        for (var i = 0; i < ws.length; i++) {
//			wis +=	parseInt(ws[i].split(':')[1]);
            var fontNum = parseInt(( ws[i].split(':')[2] ).length);
            wis += fontNum * 20;
//            alert(wis);
            right_index = i;
            if (wis > width_document - 240) {
                break;
            }
        }
        if (right_index < size - 1) {

            for (var j = right_index + 1; j < size; j++) {
                $("#ulli_" + j).hide();
            }
            $(".simpleTab_top").prepend("<li id='left_button' style='width:20px'><a onclick='javascript: trunleftorright(0)' target='frmrightChild' style='width:20px'>"
                    + "<span class='' style='width:16px;padding: 0 0 0 0;color:green'>《</span></a></li>");
            $(".simpleTab_top").append("<li id='right_button' style='width:20px'><a onclick='javascript: trunleftorright(1)' target='frmrightChild' style='width:20px'>"
                    + "<span class='' style='width:16px;padding: 0 0 0 0;color:green'>》</span></a></li>");
            $("#left_button span").addClass("icon_btn_left");
        }
        changeTurnButton();
    }
    function trunleftorright(obj) {
        if (obj == 0) {
            if (left_index != 0) {
                left_index -= 1;
                right_index -= 1;
            }
        } else {
            if (right_index != size - 1) {
                left_index += 1;
                right_index += 1;
            }
        }
        for (var i = 0; i < size; i++) {
            if (i < left_index || i > right_index) {
                $("#ulli_" + i).hide();
            } else {
                $("#ulli_" + i).show();
            }
        }
        var current_index = parseInt($("li[id^='ulli_'][class='current']").attr("id").substr(5));
        if (current_index < left_index || current_index > right_index) {
            $("li[id='ulli_" + current_index + "']").removeClass("current");
            $("li[id='ulli_" + left_index + "']").addClass("current");
            $("li[id='ulli_" + left_index + "'] a span").click();
        }
        changeTurnButton();
    }
    function changeTurnButton() {
        if (left_index != 0) {
            $("#left_button").show();
        } else {
            $("#left_button").hide();
        }
        if (right_index != size - 1) {
            $("#right_button").show();
        } else {
            $("#right_button").hide();
        }
    }
</script>
<style type="text/css">
    .ffb .page, .ffb a.page {
        font-size: 12px;
    }
</style>
</head>

<body style="text-align:center;">

<div class="box1" panelWidth="100%">
    <s:form name="theform" method="post" theme="simple">
        <s:hidden name="tsysUser.userid"/>
        <s:hidden name="tsysUser.usertype"/>
        <s:hidden id="userPwd_hide" name="userPwd_hide" value="%{tsysUser.userpwd}"/>
        <%--<s:hidden id="departid" name="tsysUser.depart.departid" />--%>
        <s:hidden id="departname" name="tsysUser.depart.departname"/>
        <s:hidden id="menues" name="menues"/>
        <%--这边是角色编号--%>
        <s:hidden name="rolesId" id="rolesId"/>
        <table width="100%" border="0" align="center">
            <tr>
                <td width="3%">&nbsp;</td>
                <td align="center" width="28%" nowrap="nowrap">登录帐号：<s:textfield id="userLoginId"
                                                                                 name="tsysUser.userloginid"
                                                                                 maxlength="50" size="15"/> <label
                        style="color:red">*</label></td>
                <td align="left" width="30%" nowrap="nowrap">登录密码：<input type="password"
                                                                         value="<s:property value="tsysUser.userpwd"/>"
                                                                         id="userPwd" name="tsysUser.userpwd"
                                                                         maxlength="30" size="15"/> <label
                        style="color:red">*</label></td>
                <td align="left">用户状态：<s:select id="userState" name="tsysUser.state"
                                                value="%{tsysUser==null?'1':tsysUser.state}" list="#{'1':'可用','0':'禁用'}"
                                                listKey="key" listValue="value" onchange="changeRightCtrl()"
                                                cssClass="default" cssStyle="height: 20px;width: 120px"/>
                </td>
                <td width="3%">&nbsp;</td>
            </tr>
        </table>
        <%--<table width="96%" border="0" align="center">--%>
        <%--<tr>--%>
        <%--<td height="1" style="background-color: silver"></td>--%>
        <%--</tr>--%>
        <%--</table>--%>

        <table width="100%" border="0" align="center">
            <tr>
                <td width="3%">&nbsp;</td>
                <td align="center" width="28%" nowrap="nowrap">用户名称：<s:textfield id="userName" name="tsysUser.username"
                                                                                 maxlength="50" size="30"/> <label
                        style="color:red">*</label></td>
                <td align="left" colspan="3" nowrap="nowrap">
                    <table>
                        <tr>
                            <td>所属部门：</td>
                            <td>
                                <div class="abcdefg" id="tsysUser.depart.departid" style="height: 23px"></div>
                            </td>
                            <td style="text-align: left"><span style="color:red">*</span></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>


        <%--<table width="96%" border="0" align="center">--%>

        <%--<tr>--%>
        <%--<td height="1" style="background-color: silver"></td>--%>
        <%--</tr>--%>
        <%--</table>--%>
        <table id="userRightCtrl_role" width="100%" border="0" align="center">
            <tr>
                <td align="left" width="100%" nowrap="nowrap" colspan="5">
                    <div class="box1" panelWidth="600" align="left">
                        <div class="simpleTab" iframeMode="true">
                            <ul class="simpleTab_top">
                                <s:iterator value="AccessApp" status="stuts">
                                    <li id='ulli_<s:property value="%{#stuts.index}"/>'>
                                        <a href="${basePath}/id/idRoleButton-list.action?appId=<s:property value="appid"/>"
                                           target="frmrightChild">
                                            <span><s:property value="appname"/></span></a></li>
                                </s:iterator>
                            </ul>
                            <div class="simpleTab_con">
                                <IFRAME scrolling="no" width="100%" frameBorder=0 id=frmrightChild
                                        name=frmrightChild onload="iframeHeight('frmrightChild')"
                                        src="${basePath}/id/idRoleButton-list.action?appId=<s:property value='appid'/>"
                                        allowTransparency="true"></IFRAME>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
        <%--<table width="96%" border="0" align="center">--%>
        <%--<tr>--%>
        <%--<td height="1" style="background-color: silver"></td>--%>
        <%--</tr>--%>
        <%--</table>--%>

    </s:form>
</div>
<div class="padding_top10">
    <table class="tableStyle" transMode="true">
        <tr>
            <td colspan="4">
                <input type="button" id="ysSaveButton" value=" 保 存 " onclick="doSave()"/>
                <input type="button" value=" 关 闭 " onclick="parent.closeEntityWindow()"/>
                <s:if test="actionErrors.size()>0 || actionMessages.size()>0 || fieldErrors.size()>0">
						<span id="SystemErrorMessage" style="top: 20px">
							<s:actionerror cssStyle="color:red"/>
							<s:actionmessage cssStyle="color:blue"/>
							<s:fielderror/>
						</span>
                </s:if>
            </td>
        </tr>
    </table>
</div>
</div>

</body>
</html>
